// 引入mockjs
const VueMock = require('mockjs');
// 获取mock.Random对象
const Random = VueMock.Random;
// mock一组数据
const newIndex = function () {
    let news = [];
    for(var i = 0; i < 20; i++) {
        let newItem = {
            title: Random.ctitle(15, 30),
            desc: Random.csentence(80, 120),
            homeSpread: Random.boolean(),
            natural: Random.natural(500, 3000),
            string: Random.string(10),
            createDate: Random.date('yyyy-MM-dd HH:mm:ss'),
            nowTime: Random.now(),
            name: Random.cname(),
            imgUrl: Random.image('200x200', Random.color()),
            url: Random.url('http'),
            address: {
                province: Random.province(),
                city: Random.city(),
                county: Random.county(),
                txt: Random.ctitle(5, 15),
                zip: Random.zip()
            }
        }
        news.push(newItem);
    }

    return {
        code: 200,
        reqTime: Random.natural(500, 1500),
        news: news
    }
};

VueMock.mock('/news/index', 'post', newIndex);